home *** CD-ROM | disk | FTP | other *** search
/ Basic Instinct 2 Press Kit / Basic Instinct 2 Press Kit.iso / pc / main.dxr / FlashPaper_1_BIProdNotes.swf / scripts / __Packages / FPUI / Tree.as < prev    next >
Encoding:
Text File  |  2006-03-15  |  2.5 KB  |  100 lines

  1. class FPUI.Tree extends FPUI.SelectableList
  2. {
  3.    function Tree()
  4.    {
  5.       var _loc1_ = this;
  6.       super();
  7.       _loc1_._x = Math.round(_loc1_._x);
  8.       _loc1_._y = Math.round(_loc1_._y);
  9.       _loc1_.m_width = _loc1_._width;
  10.       _loc1_.m_height = _loc1_._height;
  11.       _loc1_._yscale = _loc1_._xscale = 100;
  12.       _loc1_.setSize(_loc1_.m_width,_loc1_.m_height);
  13.    }
  14.    function refresh()
  15.    {
  16.       this.refreshBranch(-1);
  17.    }
  18.    function refreshBranch(index)
  19.    {
  20.       var _loc1_ = this;
  21.       _loc1_.m_dataProvider.updateBranch(index);
  22.       _loc1_.rebuildSelectedItems();
  23.       _loc1_.invalidate("updateControl");
  24.    }
  25.    function setDataProvider(dataProvider)
  26.    {
  27.       var _loc1_ = this;
  28.       _loc1_.clearSelected();
  29.       super.setDataProvider(dataProvider);
  30.       _loc1_.resetTreeWidth();
  31.       _loc1_.refresh();
  32.    }
  33.    function setSize(w, h)
  34.    {
  35.       super.setSize(w,h);
  36.       this.setMinHighlightWidth(Stage.width);
  37.    }
  38.    function moveSelBy(incr)
  39.    {
  40.       var _loc1_ = this.getSelectedItem();
  41.       if(_loc1_ != null && _loc1_.isOnOpenBranch())
  42.       {
  43.          super.moveSelBy(incr);
  44.       }
  45.       this.executeCallBack();
  46.    }
  47.    function resetTreeWidth()
  48.    {
  49.       var _loc1_ = this;
  50.       _loc1_.m_virtualWidth = _loc1_.m_dataProvider.calcWidth();
  51.       _loc1_.setMinHighlightWidth(Stage.width);
  52.       _loc1_.invalidate("updateControl");
  53.    }
  54.    function setMinTreeWidth(w)
  55.    {
  56.       var _loc1_ = this;
  57.       if(w > _loc1_.m_virtualWidth)
  58.       {
  59.          _loc1_.m_virtualWidth = w;
  60.          _loc1_.setMinHighlightWidth(_loc1_.m_virtualWidth);
  61.          _loc1_.invalidate("initScrollBar");
  62.       }
  63.    }
  64.    function setMinHighlightWidth(width)
  65.    {
  66.       var _loc2_ = this;
  67.       var _loc3_ = width;
  68.       var _loc1_ = 0;
  69.       while(_loc1_ < _loc2_.m_numDisplayed)
  70.       {
  71.          _loc2_.getNthSelectableItem(_loc1_).setMinHighlightWidth(_loc3_);
  72.          _loc1_ = _loc1_ + 1;
  73.       }
  74.    }
  75.    function onComponentKeyDown()
  76.    {
  77.       var _loc2_ = this;
  78.       if(_loc2_.m_focused && _loc2_.m_enable)
  79.       {
  80.          if(Key.isDown(32))
  81.          {
  82.             var _loc1_ = _loc2_.getSelectedItem();
  83.             if(_loc1_ != null && _loc1_.isBranch())
  84.             {
  85.                _loc1_.setIsOpen(!_loc1_.isOpen());
  86.                _loc2_.refreshBranch(_loc2_.getSelectedIndex());
  87.             }
  88.          }
  89.          else
  90.          {
  91.             super.onComponentKeyDown();
  92.          }
  93.       }
  94.    }
  95.    function getItemSymbolName()
  96.    {
  97.       return "FPUI_TreeSelectableItem";
  98.    }
  99. }
  100.